import ciso8601


class TimeTransformer:
    @staticmethod
    def time2ts(h_time: str) -> float:
        """
        将人类可读的时间转换成时间戳
        需要符合ISO格式
        :param h_time: 时间字符串
        :return: 13位时间戳（精确到ms）
        """
        orig_ts = ciso8601.parse_datetime(h_time).timestamp()
        return orig_ts * 1000


if __name__ == '__main__':
    print(TimeTransformer.time2ts('2021-07-24T13:56:05.465Z'))
    print(TimeTransformer.time2ts('2021-07-24T13:56:05'))
    print(TimeTransformer.time2ts('2021-07-24 13:56:05'))
    print(TimeTransformer.time2ts('2021-07-17 15:59:32.3731882'))
